#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdbool.h>

int main(int argc, char* argv[], char* envp[])
{
    extern char** environ;
    printf("1\n");
    printf("1\n");
    printf("1\n");
    
//    int ret = execl("/usr/bin/ls", "ls", "-l", NULL);
//    int ret = execlp("ls", "ls", "-l", NULL);
    char * const myenvp[] = {
        "myval=12",
        "MYVAL=21",
        NULL
    };
    putenv("myval=22");
    //setenv("PATH","/home/cloudy_night/bin/b",true);
    printf("envp[0] addr:%p, environ[0] addr:%p\n",envp,environ);
    int a;
    printf("stack addr:%p\n", &a);
    

    char* const args[] = {
        "ls",
        "-ln",
        NULL
    };
    //int ret = execle("../envp/envp", "envp", NULL, environ);
    //int ret = execv("../envp/envp", args);
    int ret = execvpe("ls", args, environ);
    //int ret = execvpe("envp", args, myenvp);
    //int ret = execve("../envp/envp", args, myenvp);
    //int ret = execve("./shell.sh", args, environ);
    //int ret = execl("./test.py", "test.py", "-test", NULL);
    printf("ret=%d\n",ret);

    printf("2\n");
    printf("2\n");
    printf("2\n");
    return 0;
}
